<?php 
	include('template/header.php');
	include('classess/user_subscribe.php');
	$usr = new User_subscribe();
	if(isset($_POST['billing_user_name'])){
		$usr_info = $usr->saveUserInfoAfterBilling();		
	}
?>
	<!-- Page Content -->
	<style>
		.chkbox_compul{
			margin-top:-3px !important;
		}
		.label_nxt_chkbox{
			display: inline-block;
			margin-left: 1%;
			font-size: 13px;
		}
		#via_paid_dtl{
			display:none;
		}
		#ur_bnk_info{
			display:none;
		}
		.datepicker{
			z-index: 99999999999;
		}
	</style>
	<section  class="homepage-slider" id="home-slider">
		<div class="flexslider">
			<ul class="slides">
				<li>
					<img src="img/slider/first_image.jpg" alt="No Image" />					
				</li>
				<li>
					<img src="img/slider/second_image.jpg" alt="No Image" />					
				</li>
			</ul>
		</div>			
	</section>
	<section class="header_text sub">
		<h4><span>Check Out</span></h4>
	</section>	
	<section class="main-content">
		<div class="row">
			<form action="<?php echo $_SERVER['PHP_SELF']; ?>?home=1" method="POST" name="email_subscribe" >
				<div class="span12">
					<div class="accordion" id="accordion2">					
						<div class="accordion-group">
							<div class="accordion-heading">
								<a class="accordion-toggle" data-toggle="collapse">User Details</a>
							</div>						
							<div id="collapseTwo" class="accordion-body collapse in" style="height: auto;">
								<div class="accordion-inner">
									<div class="row-fluid">									
									<div class="span6">
										<h4>Your Personal Details</h4>
										
										<div class="control-group">
											<label class="control-label">First Name</label>
											<div class="controls">
												<input type="text" name="billing_user_name" id="billing_user_name" placeholder="Name" class="input-xlarge" value="">
											</div>
										</div>
										<div class="control-group">
											<label class="control-label">Phone</label>
											<div class="controls">
												<input type="text" name="billing_user_phone" id="billing_user_phone" class="input-xlarge" placeholder="Phone" required/>
											</div>
										</div><div class="control-group">
											<label class="control-label">Email Id</label>
											<div class="controls">
												<input type="text" name="billing_user_email" id="billing_user_email" class="input-xlarge" placeholder="Email" required/>
											</div>
										</div>
										<div class="control-group">
											<label class="control-label">Address</label>
											<div class="controls">
												<input type="text" name="billing_user_address" id="billing_user_address" class="input-xlarge" placeholder="Address" required/>
											</div>
										</div>
										<div class="control-group">
											<label class="control-label">Skills:</label>
											<div class="controls">
												<select name="user_skills" id="user_skills" class="input-xlarge">
													<option value="Marketing">Marketing</option>
													<option value="Sales">Sales</option>
													<option value="Webdeveloper">Web Developer</option>
												 </select>
											</div>
										</div>
									</div>
									<div class="span6">
										<h4>Your Address</h4> 
										<div class="control-group">
											<label class="control-label">City:</label>
											<div class="controls">
												<input type="text" name="billing_user_city" id="billing_user_city" class="input-xlarge" placeholder="City" required/>
											</div>
										</div>
										<div class="control-group">
											<label class="control-label">State:</label>
											<div class="controls">
												<input type="text" name="billing_user_state" id="billing_user_state" placeholder="State" class="input-xlarge" required/>
											</div>
										</div>
										<div class="control-group">
											<label class="control-label">Zip Code:</label>
											<div class="controls">
												<input type="text" name="billing_user_zip" id="billing_user_zip" class="input-xlarge" placeholder="Zip" required/>
											</div>
										</div>
										<div class="control-group">
											<label class="control-label">Country:</label>
											<div class="controls">
												<input type="text" name="billing_user_country" id="billing_user_country" class="input-xlarge" placeholder="Country" required/> 
											</div>
										</div>
										<div class="control-group">
											<input type="checkbox" name="terms_of_cond" id="terms_of_cond" class="chkbox_compul">
											<label class="control-label label_nxt_chkbox">Terms Of Condition</label>											
										</div>
										<div class="control-group">
											<input type="checkbox" name="privacy_policy" id="privacy_policy" class="chkbox_compul">
											<label class="control-label label_nxt_chkbox">Privacy Policy</label>											
										</div>
										<div class="control-group">
											<input type="checkbox" name="terms_of_use" id="terms_of_use" class="chkbox_compul">
											<label class="control-label label_nxt_chkbox">Terms Of Use</label>											
										</div>

									</div>
									<?php 
										if(isset($_GET['ebk_chk'])){ 
											echo '<input type="hidden" name="is_ebook_chk" id="is_ebook_chk" value="1">';
										}
									?>
									<button class="btn btn-inverse pull-right" name="submit_form" id="submit_form">Pay</button>
									
									</div>
								</div>
							</div>
						</div>					
					</div>
				</div>
				<div class="span12" id="via_paid_dtl">
					<div class="accordion" id="accordion2">					
						<div class="accordion-group">
							<div class="accordion-heading">
								<a class="accordion-toggle" data-toggle="collapse">Paid</a>
							</div>	
							<div id="collapseTwo" class="accordion-body collapse in" style="height: auto;">
								<div class="accordion-inner">
									<div class="row-fluid">									
										<div class="span6">
											<h4>Via Bank</h4>
											<div class="control-group">
												<input type="checkbox" name="pm_method_bank" id="pm_method_bank" class="chkbox_compul">
												<label class="control-label label_nxt_chkbox">Bank</label>
											</div>
											<div id="ur_bnk_info">
												<h4>Your Bank Info</h4> 
												<div class="control-group">
													<label class="control-label">Bank Name:</label>
													<div class="controls">
														<input type="text" name="billing_user_bank_name" id="billing_user_bank_name" class="input-xlarge" placeholder="Bank Name" />
													</div>
												</div>
												<div class="control-group">
													<label class="control-label">Branch Name:</label>
													<div class="controls">
														<input type="text" name="billing_user_branch_name" id="billing_user_branch_name" placeholder="Branch Name" class="input-xlarge" />
													</div>
												</div>
												<div class="control-group">
													<label class="control-label">Account Number:</label>
													<div class="controls">
														<input type="text" name="billing_user_acc_num" id="billing_user_acc_num" class="input-xlarge" placeholder="Account Number" />
													</div>
												</div>
												<div class="control-group">
													<label class="control-label">Date</label>
													<div class="controls">
														<input type="text" name="billing_user_date" id="billing_user_date" class="form-control date-picker input-xlarge" data-date-format="yyyy-mm-dd" readonly placeholder="Click Here toSelect Date" /> 
													</div>
												</div>
											</div>
											<div><h4>Bank Details</h4></div>
											<div class="bank_detail_row">
												<div class="fl_left bnk_label">Bank Account Name</div>
												<div class="fl_left bnk_semcol">:</div>
												<div class="fl_left bnk_desc">Vipin Chauhan</div>
												<div class="fl_clear"></div>
											</div>
											<div class="bank_detail_row">
												<div class="fl_left bnk_label">Account No</div>
												<div class="fl_left bnk_semcol">:</div>
												<div class="fl_left bnk_desc">159301501967</div>
												<div class="fl_clear"></div>
											</div>
											<div class="bank_detail_row">
												<div class="fl_left bnk_label">IFSC Code</div>
												<div class="fl_left bnk_semcol">:</div>
												<div class="fl_left bnk_desc">ICIC0001593</div>
												<div class="fl_clear"></div>
											</div>
											<div class="bank_detail_row">
												<div class="fl_left bnk_label">Branch Code</div>
												<div class="fl_left bnk_semcol">:</div>
												<div class="fl_left bnk_desc">001593</div>
												<div class="fl_clear"></div>
											</div>
											<div class="bank_detail_row">
												<div class="fl_left bnk_label">Branch</div>
												<div class="fl_left bnk_semcol">:</div>
												<div class="fl_left bnk_desc">Chakrata Road, Dehra Dun-248001, Uttarakhand, India </div>
												<div class="fl_clear"></div>
											</div>
											<div class="bank_detail_row">
												<div class="fl_left bnk_label">Mob</div>
												<div class="fl_left bnk_semcol">:</div>
												<div class="fl_left bnk_desc">+91-9997909316, +91-8755665529</div>
												<div class="fl_clear"></div>
											</div>
										</div>
										<div class="span6">
											<h4>Via Paypal</h4> 
											<div class="control-group">
												<input type="checkbox" name="pm_method_paypal" id="pm_method_paypal" class="chkbox_compul">
												<label class="control-label label_nxt_chkbox">Paypal</label>											
											</div>
										</div>
									</div>
								</div>
							</div>
						</div>					
					</div>
				</div>
			</form>	
		</div>
	</section>
	<!-- /.content-section-a -->	
   
<?php include('template/footer.php'); ?>
<script type="text/javascript" src="js/bootstrap-datepicker.min.js"></script>
<script>
	$ = jQuery.noConflict();
	$(document).ready(function(){	
		var regex = /(\d.*){10}/;
		var regex1 = /([^\d]+)/g;
		var phnVal = $('#billing_user_phone').val().replace(regex1,'');
		var number = /(\d)\1{9}/;
		
		$('.date-picker').datepicker();	

		$('#billing_user_date').datepicker({format: 'yyyy-mm-dd'}).on('changeDate', function(e){
			$(this).datepicker('hide');
		});

		$('#terms_of_cond').click(function(){
			if($('#privacy_policy:checked').length != '0' && $('#terms_of_use:checked').length != '0'){
				$('#via_paid_dtl').css('display','block');
			}
		});

		$('#privacy_policy').click(function(){
			if($('#terms_of_cond:checked').length != '0' && $('#terms_of_use:checked').length != '0'){
				$('#via_paid_dtl').css('display','block');
			}
		});

		$('#terms_of_use').click(function(){
			if($('#privacy_policy:checked').length != '0' && $('#terms_of_cond:checked').length != '0'){
				$('#via_paid_dtl').css('display','block');
			}
		});
		
		//$('#pm_method_bank:checked').length == '0' && $('#pm_method_paypal:checked').length == '0'
		$('#pm_method_bank').click(function(){
			if($('#pm_method_paypal:checked').length != '0'){
				document.getElementById("pm_method_paypal").checked = false;
			}

			if($('#ur_bnk_info').css('display') == 'none'){
				$('#ur_bnk_info').css('display','block');
			}
		});

		$('#pm_method_paypal').click(function(){
			if($('#pm_method_bank:checked').length != '0'){
				document.getElementById("pm_method_bank").checked = false;
			}

			if($('#ur_bnk_info').css('display') == 'block'){
				$('#ur_bnk_info').css('display','none');
			}
		});
		
		
		$('#submit_form').click(function(){
			if($('#billing_user_name').val().trim() == ''){			
				alert("Please enter a value for the \"User Name\" field.");
				$('#billing_user_name').focus();
				return (false);
			}
			else if($('#billing_user_phone').val().trim() == ""){
				alert("Please enter a value for the \"User Phone \" field.");
				$('#billing_user_phone').focus();				
				return (false);
			}
			else if(!$('#billing_user_phone').val().match(regex))
			{
				alert("Please enter your complete 10 digit phone number.");
				$('#billing_user_phone').focus();
				return (false);
			} 
			else if(phnVal.match(number))
			{
				alert("Please enter proper 10 digit phone number.");
				$('#billing_user_phone').focus();
				return (false);
			}
			else if($('#billing_user_email').val().trim() == "")
			{
				alert("Please enter a value for the \"Email\" field.");
				$('#billing_user_email').focus();				
				return (false);
			}
			else if(($('#billing_user_email').val().indexOf("\@") == -1) || ($('#billing_user_email').val().indexOf(".")== -1) || isInvalidateEmail($('#billing_user_email').val()))
			{
				alert("Invalid Email Address");
				$('#billing_user_email').focus();
				return (false);
			}
			else if($('#billing_user_address').val().trim() == ""){
				alert("Please enter a value for the \"User Address \" field.");
				$('#billing_user_address').focus();				
				return (false);
			}
			else if($('#billing_user_city').val().trim() == ""){
				alert("Please enter a value for the \"User City \" field.");
				$('#billing_user_city').focus();				
				return (false);
			}
			else if($('#billing_user_state').val().trim() == ""){
				alert("Please enter a value for the \"User State \" field.");
				$('#billing_user_state').focus();				
				return (false);
			}
			else if($('#billing_user_zip').val().trim() == ""){
				alert("Please enter a value for the \"User Zip \" field.");
				$('#billing_user_zip').focus();				
				return (false);
			}			
			else if(isNaN($('#billing_user_zip').val()))
			{
				alert("Please Enter Numeric Code.");
				$('#billing_user_zip').focus();	
				return (false);
			}
			else if($('#billing_user_country').val().trim() == ""){
				alert("Please enter a value for the \"User Country \" field.");
				$('#billing_user_country').focus();				
				return (false);
			}
			else if($('#terms_of_cond:checked').length == '0'){
				alert("Please Select Terms And Condition Checkbox.");
				return (false);
			}else if($('#privacy_policy:checked').length == '0'){
				alert("Please Select Privacy Policy Checkbox.");
				return (false);
			}else if($('#terms_of_use:checked').length == '0'){
				alert("Please Select Terms And Use Checkbox.");
				return (false);
			}else if($('#pm_method_bank:checked').length == '0' && $('#pm_method_paypal:checked').length == '0'){
				alert("Please Select One Payment Method Via Paypal or Bank.");
				return (false);
			}else if($('#ur_bnk_info').css('display') == 'block' && $('#billing_user_bank_name').val().trim() == ""){
				alert("Please enter a value for the \" Bank Name \" field.");
				$('#billing_user_bank_name').focus();
				return (false);
			}else if($('#ur_bnk_info').css('display') == 'block' && $('#billing_user_branch_name').val().trim() == ""){
				alert("Please enter a value for the \" Branch Name \" field.");
				$('#billing_user_branch_name').focus();
				return (false);
			}else if($('#ur_bnk_info').css('display') == 'block' && $('#billing_user_acc_num').val().trim() == ""){
				alert("Please enter a value for the \" Account Number \" field.");
				$('#billing_user_acc_num').focus();
				return (false);
			}else if($('#ur_bnk_info').css('display') == 'block' && $('#billing_user_date').val().trim() == ""){
				alert("Please enter a value for the \" Date \" field.");
				$('#billing_user_date').focus();
				return (false);
			}
			else{
				document.email_subscribe.submit();
			}		

		});
	});
		
	function isInvalidateEmail(str)
	{
		var atpos=str.indexOf("@");
		var dotpos=str.lastIndexOf(".");
		if (atpos<1 || dotpos<atpos+2 || dotpos+2>=str.length)
		  {
		  return true;
		  }
		return false;
	}
</script>